home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1198 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do you pass along a variable argument list?
  5. Date: Fri, 12 Jan 1996 03:54:38 GMT
  6. Organization: Netcom
  7. Message-ID: <30f5cfa3.8792640@nntp.ix.netcom.com>
  8. References: <4d1i8v$k8h@news.mcl.bdm.com> <4d30nv$k8r@tahko.lpr.carel.fi> <TANMOY.96Jan11091945@qcd.lanl.gov>
  9. NNTP-Posting-Host: ix-dc7-22.ix.netcom.com
  10. X-NETCOM-Date: Thu Jan 11  7:54:37 PM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) wrote:
  14.  
  15. |>--text follows this line--
  16. |>In article <4d30nv$k8r@tahko.lpr.carel.fi>
  17. aril@cmt.lpr.mail.carel.fi
  18. |>(Ari Lukumies) writes: 
  19. |><snip>
  20. |>   >Hi, there:
  21. |>
  22. |>   >I am writing a wrapper around a routine which takes variable
  23. |>argument list only. I   
  24. |>   >want my wrapper has the similar prototype and can pass the
  25. |>variable arguments   
  26. |>   >directly to the routine(by the way, I cannot change the code of
  27. |>that routine). 
  28. |>
  29. |>   >I guess it is really hard to do it in ANSI, and I know how to do
  30. |>it in a stupid   
  31. |>   >way---but, is there any way around??
  32. |>
  33. |>   >Thanks!!
  34. |>
  35. |>   >Yibing Wu
  36. |>   >ywu@plato.sky.bdm.com
  37. |>
  38. |>   Actually, it's not so difficult. Here's an ANSI-compliant example
  39. that
  40. |>   wraps the printf function:
  41. |>
  42. |>Huh?! The FAQ describes that it is impossible in ANSI C: and you
  43. claim
  44. |>it is not difficult? 
  45. |>
  46. |>   #include    <stdio.h>
  47. |>   #include    <stdarg.h>
  48. |>
  49. |>   void    MyPrintf(char *fmt, ...)
  50. |>   {
  51. |>       va_list    argp;
  52. |>
  53. |>       va_start(argp, fmt);
  54. |>       printf(fmt, argp);
  55. |>
  56. |>Did you try this? A conforming compiler is _required_ to diagnose
  57. this.
  58. |>
  59. |>       va_end(argp);
  60. |>   }
  61.  
  62. I'm missing something here.  Why is a conforming compiler required to
  63. diagnose this?  As I read ISO 7.8, a conforming compiler could define
  64. va_list as
  65.  
  66.     typedef int va_list;
  67.  
  68. in which case this code is legal.
  69.  
  70. In fact, I can find no constraings or syntax requirements in 7.9.6.1
  71. or 7.9.6.3 that would require a diagnostic no matter what the type of
  72. va_list is.
  73.  
  74.  
  75. Michael M Rubenstein
  76.